<?php
	if ($current_day == 1) {
		if ($month == 1) {
			$temp_month = 12;
			$temp_year = $year - 1;
		}
		else {
			$temp_month = $month - 1;
			$temp_year = $year;
		}
		$prev_month_offset = cal_days_in_month(0, $temp_month, $year);
		$temp_day = $prev_month_offset;	
	}
	else {
		$temp_day = $current_day - 1;
		$temp_month = $month;
		$temp_year = $year;
	}
?>

<a href="viewDay.php?day=<?php echo $temp_day ?>&month=<?php echo $temp_month ?>&year=<?php echo $temp_year ?>">&lt;</a> 

<?php echo "<span class='dateheader'>$month_name $current_day, $year</span>"; ?>

<?php
	$month_days = cal_days_in_month(0, $month, $year);
	if ($current_day == $month_days) {
		$temp_day = 1;
		if ($month == 12) {
			$temp_month = 1;
			$temp_year = $year + 1;
		}
		else {
			$temp_month = $month + 1;
			$temp_year = $year;
		}
	}
	else {
		$temp_day = $current_day + 1;
		$temp_month = $month;
		$temp_year = $year;
	}
?>

<a href="viewDay.php?day=<?php echo $temp_day ?>&month=<?php echo $temp_month ?>&year=<?php echo $temp_year ?>">&gt;</a> 